<!--
  @author duanzuocai
  @since 2018/12/13 13:21
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head th:include="common/common :: jscss">
    <title>新增或编辑模块权限</title>
</head>
<body>

<div class="layui-fluid">

    <blockquote class="layui-crumb">
        系统管理>
        <a lay-href="/mc/permit/list.action" lay-text="权限管理" th:text="权限管理">权限管理</a>
        >
        <span th:text="${permit.parentId>0 ? permit.permitName:'添加权限'}"></span>
    </blockquote>

    <div class="layui-card">
        <form method="post" action="" class="layui-form" lay-filter="zmn-permit-form">
            <input type="hidden" name="permitId" id="permitId" th:value="${permit.permitId}"/>

            <div class="layui-card-header" style="margin-top:10px;"><b>基本信息</b></div>
            <div class="layui-split">&nbsp;</div>

            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">所属模块</label>
                <div class="layui-input-inline" style="width:600px;" th:if="${permit.permitId <= 0}">
                    <select name="moduleId" id="moduleId" xm-select="moduleId" lay-verify="required" xm-select-radio>
                        <option value="">请选择</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width:240px;" th:if="${permit.permitId > 0}">
                    <input type="text" th:value="${module.moduleName}" autocomplete="off" class="layui-input" maxlength="50" readonly/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">权限名称</label>
                <div class="layui-input-inline" style="width:240px;">
                    <input type="text" name="permitName" lay-verify="required" th:value="${permit.permitName}" autocomplete="off" class="layui-input" maxlength="50"/>
                </div>
            </div>
            <!--<div class="layui-form-item">
                <label class="layui-form-label layui-form-required">权限码</label>
                <div class="layui-input-inline" style="width:240px;">
                    <input type="text" th:value="${permit.permitCode}" autocomplete="off" class="layui-input" lay-verify="required"
                           th:if="${permit.permitId <= 0}" name="permitCode" maxlength="50" />
                    <input type="text" th:value="${permit.permitCode}" autocomplete="off" class="layui-input" lay-verify="required"
                           th:if="${permit.permitId > 0}" maxlength="50" readonly />
                </div>
            </div>-->
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">url</label>
                <div class="layui-input-inline" style="width:240px;">
                    <input type="text" name="url" lay-verify="required" th:value="${permit.url}" autocomplete="off" class="layui-input" maxlength="150"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">排序</label>
                <div class="layui-input-inline" style="width:240px;">
                    <input type="text" name="sort" lay-verify="sort" th:value="${permit.sort}" autocomplete="off" class="layui-input" maxlength="6"/>
                </div>
                <div class="layui-form-mid layui-word-aux">越小越靠前</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">上级菜单ID</label>
                <div class="layui-input-inline" style="width:240px;">
                    <input type="text" name="parentId" lay-verify="parentId" th:value="${permit.parentId}" autocomplete="off" class="layui-input" maxlength="11"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">是否按钮</label>
                <div class="layui-input-inline" style="width:240px;" id="isButton">
                    <input type="radio" name="button" value="1" title="否"
                           th:checked="${permit.button == null || permit.button ==0 || permit.button ==1}">
                    <input type="radio" name="button" value="2" title="是"
                           th:checked="${permit.button == 2}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">状态</label>
                <div class="layui-input-inline">
                    <select name="status" lay-verify="required">
                        <option th:each="status:${statuses}" th:value="${status.key}" th:text="${status.value}"
                                th:selected="${status.key == permit.status}">
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">备注</label>
                <div class="layui-input-inline" style="width:400px;">
                    <textarea name="remark" maxlength="100" class="layui-textarea" th:text="${permit.remark}" th:value="${permit.remark}"></textarea>
                </div>
            </div>

            <div class="layui-split">&nbsp;</div>
            <div class="layui-form-item layui-layout-admin">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn" lay-submit="" lay-filter="zmn-permit-form-submit" th:if="${#authPermit.checkPermit('/mc/permit/addEdit.action')}">保存</button>
                        <button class="layui-btn layui-btn-primary" onclick="parent.layui.element.tabDelete('layadmin-layout-tabs', window.location.pathname + window.location.search)">取消</button>
                    </div>
                </div>
            </div>

        </form>
    </div>
</div>

<script type="text/javascript" th:inline="javascript">

    layui.config({
        base: "/static/lay/"
    }).extend({
        index: "lib/index",
        art_permit_detail: "mc/permit/zmn.art.permit.edit",
    }).use(['index', 'art_permit_detail']);

    function initSelect() {
        var formSelects = layui.formSelects;
        formSelects.config('moduleId', {
            keyName: 'value',
            keyVal: 'key',
            keyChildren: 'list',
            success: function(id, url, val, result){
                formSelects.value('moduleId', ['[[${permit.moduleId}]]']);
                console.log(id);
            },
            error: function(id, url, val, err){
                console.log(id + ":" +　err);
            }
        });

        formSelects.data('moduleId', 'server', {
            url: '/mc/module/findAllModule.action',
            linkage: false,
            linkageWidth: 130
        });
    }
    window.onload = initSelect;
</script>
</body>
</html>